//
// [Author] lg (https://github.com/lemos1235)
// [Date] 2025/5/4
//
import 'package:flutter/material.dart';
import 'package:forui/forui.dart';
import 'package:icoffee/screens/home/home_screen.dart';
import 'package:icoffee/screens/statistics/statistics_screen.dart';
import 'package:icoffee/screens/beans/beans_screen.dart';
import 'package:icoffee/screens/personal/personal_screen.dart';

class MainScreen extends StatefulWidget {
  const MainScreen({super.key});

  @override
  State<MainScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
  int _currentPage = 0;
  final List<Widget> _pages = [
    const HomeScreen(),
    const StatisticsScreen(),
    const BeansScreen(),
    const PersonalScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return FScaffold(
      childPad: false,
      footer: FBottomNavigationBar(
        index: _currentPage,
        onChange: (index) => setState(() => _currentPage = index),
        children: [
          FBottomNavigationBarItem(
            icon: Icon(FIcons.house),
            label: const Text('首页'),
          ),
          FBottomNavigationBarItem(
            icon: Icon(FIcons.chartNoAxesCombined),
            label: const Text('统计'),
          ),
          FBottomNavigationBarItem(
            icon: Icon(FIcons.bean),
            label: const Text('咖啡豆'),
          ),
          FBottomNavigationBarItem(
            icon: Icon(FIcons.circleUserRound),
            label: const Text('我'),
          ),
        ],
      ),
      child: IndexedStack(index: _currentPage, children: _pages),
    );
  }
}
